
uniform float gTime;
uniform Texture2D gTexture;

SamplerState gTriLinearSam
{
	Filter = MIN_MAG_MIP_LINEAR;
	AddressU = Wrap;
	AddressV = Wrap;
};

struct VS_IN
{
	float3 posL     : POSITION;
	float2 texcoord : TEXCOORD0;
};

struct VS_OUT
{
	float4 posH     : SV_POSITION;
	float2 texcoord : TEXCOORD0;
};
 
VS_OUT VS(VS_IN vIn)
{
	VS_OUT vOut;
	vOut.posH = float4(vIn.posL, 1.0f);
	vOut.texcoord = vIn.texcoord;
	return vOut;
}



float4 PS(VS_OUT pIn) : SV_Target
{
	//float x = pIn.texcoord.x * 0.5f + 0.5f;
	//float y = pIn.texcoord.y * 0.5f + 0.5f;
	const float pixelOffset = 1.0f / 512.0f;
	float4 color = 
		gTexture.Sample(gTriLinearSam, pIn.texcoord + float2(-pixelOffset, 0.0f)) +
		gTexture.Sample(gTriLinearSam, pIn.texcoord + float2( pixelOffset, 0.0f)) +
		gTexture.Sample(gTriLinearSam, pIn.texcoord + float2(0.0f,  pixelOffset)) +
		gTexture.Sample(gTriLinearSam, pIn.texcoord + float2(0.0f, -pixelOffset));
		
	return color * 0.25f;
	
	/*
	return float4(saturate(abs(sin(gTime)) * y * y * y / x),
		saturate(abs(sin(gTime)) * x * x * x / y),
		saturate(abs(sin(gTime))),
		1.0f);
	*/
}

technique11 Layout
{
    pass P0
    {
        SetVertexShader( CompileShader( vs_5_0, VS() ) );
        SetGeometryShader( NULL );
        SetPixelShader( CompileShader( ps_5_0, PS() ) );
    }
}
